-
-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch HTTP client from hackney to finch #758
base: master
Are you sure you want to change the base?
Conversation
savhappy
commented
Jul 29, 2024
•
edited
Loading
edited
- switch from Hackney to Finch
- alter tests to pass with Finch
- closes Switch from Hackney to Finch as the default HTTP client #724
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start!! Left a few comments to address 🙃
@@ -253,30 +253,30 @@ defmodule Sentry.Config do | |||
The maximum number of attempts to send an event to Sentry. | |||
""" | |||
], | |||
hackney_opts: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to keep hackney_opts
and deprecate them if we want this to not be a breaking change. NimbleOptions supports deprecating options, check out the docs for that.
This also applies to the options below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we need to keep the option:
client: [
type: :atom,
type_doc: "`t:module/0`",
default: Sentry.HackneyClient,
doc: """
"""
]
and the module HackneyClient?? @whatyouhide
lib/sentry/finch_client.ex
Outdated
HTTP client, you'll have to implement your own `Sentry.HTTPClient`. See the | ||
documentation for `Sentry.HTTPClient` for more information. | ||
|
||
Finch is built on top of NimblePool. If you need to set other pool configuration options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you link to nimble_pool's repo here?
lib/sentry/finch_client.ex
Outdated
see "Pool Configuration Options" in the source code for details on the possible map values. | ||
[finch configuration options](https://github.com/sneako/finch/blob/main/lib/finch.ex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't point people to source code, that can change (especially main
). Let's link to Finch for docs
@spec finch_opts() :: keyword() | ||
def finch_opts, do: fetch!(:finch_opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we use these?
Any progress on this? A CVE (with no patched version) was issued against Hackney today: benoitc/hackney#751 |
@aselder we backlogged this yesterday but perhaps we should continue with revisions and make the switch? @whatyouhide @sl0thentr0py A quick fix is to configure your own HTTP client. |
@savhappy yeah let's pursue this. Where we at? What we need to do? |
36a8c52
to
fbd58f0
Compare
@whatyouhide it's in good shape after I fix the conflicts. I'll rerequest a review when ready |
b20ab52
to
c479fb2
Compare
@whatyouhide when we deprecate the
How do I quiet them or deprecate in a more subtle way? |
c479fb2
to
f13edfd
Compare
Start with hackney_opts: [
type: ...,
...
] ++ if(Mix.env() == :test, do: [], else: [deprecated: "..."]) |
9f4dff2
to
ee7e3e5
Compare
c925a56
to
c7d2df9
Compare
Co-authored-by: Andrea Leopardi <[email protected]>
Co-authored-by: Andrea Leopardi <[email protected]>
Co-authored-by: Andrea Leopardi <[email protected]>
Co-authored-by: Andrea Leopardi <[email protected]>
c7d2df9
to
8f3fc16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 So excited for this! ❤️
Sorry for the random review. We were starting on a quick HTTP client to replace Hackney and saw this was in progress, so I am very interested in helping push it through since it is so close. Happy to contribute changes if needed 🤠
xref: [exclude: [:hackney, :hackney_pool, Plug.Conn, :telemetry]], | ||
aliases: aliases() | ||
xref: [exclude: [Finch, Plug.Conn, :telemetry]], | ||
aliases: [aliases()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aliases: [aliases()] | |
aliases: aliases() |
@savhappy The mix test.integrations
task in CI is unavailable because this was changed to a list when the aliases/0
function already returns a list. Reverting back should get you running
@@ -298,32 +298,64 @@ defmodule Sentry.Config do | |||
The maximum number of attempts to send an event to Sentry. | |||
""" | |||
], | |||
hackney_opts: [ | |||
finch_opts: [ | |||
type: :keyword_list, | |||
default: [pool: :sentry_pool], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe pool: :sentry_pool
is not a valid option for Finch? But it also looks like finch_opts
is not used. Maybe it is best to shift to allowing a separation between Finch request_opts vs start_link opts? Sentry may not need to do intense validation since Finch also uses nimble_options under the hood
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jjcarstens for the review 💜
You're right! :sentry_pool isn't valid. The Finch config options were just placeholder until we decide what options to expose. Which of the pool options do we want to support? @whatyouhide or @jjcarstens thoughts?
Maybe it makes sense to have a catch all like you (@jjcarstens) mentioned configuration option without the need to handle validation.
finch_pool_opts: [
type: :keyword_list,
default: [size: 50, conn_max_idle_time: 5000],
doc: """
Start link pool ptions to be passed to `finch`....
"""
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The :hackney_opts
was switched to soft deprecation, but this Hackney client was totally removed which I assume is equally as breaking. Is there a specific reason not to leave it in until hackney is hard deprecated?
@@ -6,7 +6,7 @@ if config_env() == :test do | |||
tags: %{}, | |||
enable_source_code_context: true, | |||
root_source_code_paths: [File.cwd!()], | |||
hackney_opts: [recv_timeout: 50, pool: :sentry_pool], | |||
finch_opts: [recv_timeout: 50], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finch_opts: [recv_timeout: 50], | |
finch_opts: [receive_timeout: 50], |
According to t:Finch.request_opt()
, this should be :receive_timeout
@savhappy do you have an ETA for when you'd be able to make some progress on this? |
@whatyouhide working on this today. I need to add back in the Hackney client like @jjcarstens mentions so no breaking changes are introduced and await feedback on finch options to expose. After this, ready for another review. |